package pl.koziolekweb.translator.engine.googleimpl;

import java.io.FileInputStream;
import java.util.Properties;

public aspect ProxyConfig {

	private final String proxySet;
	private final String proxyHost;
	private final String proxyPort;

	public ProxyConfig() {
		final Properties properties = new Properties();
		try{
		properties.load(new FileInputStream(
				"./src/test/resources/proxy.properties"));
		}
		catch(final Exception e){
			throw new RuntimeException(e);
		}
		this.proxySet = properties.getProperty("proxySet");
		this.proxyHost = properties.getProperty("proxyHost");
		this.proxyPort = properties.getProperty("proxyPort");
	};

	pointcut config():
		execution( void pl.koziolekweb.translator.engine.googleimpl.*Test.before());

	before(): config() {
		System.out.println("[ASPECT] Configure Proxy: ");
		System.out.println("[ASPECT] Use Proxy   : " + this.proxySet);
		System.out.println("[ASPECT] Proxy Host  : " + this.proxyHost);
		System.out.println("[ASPECT] Proxy Port  : " + this.proxyPort);

		System.getProperties().put("proxySet", this.proxySet);
		System.getProperties().put("proxyHost", this.proxyHost);
		System.getProperties().put("proxyPort", this.proxyPort);
		System.out.println("[ASPECT] Proxy Configured ");
	}
}
